(function(window, document) {
    let docEl = document.documentElement;
    let wHRate = document.documentElement.clientWidth / document.documentElement.clientHeight;

    function setRemUnit() {
        let rem = docEl.clientWidth / 50;
        docEl.style.fontSize = rem + 'px';
        window.rem = rem;
    }
    setRemUnit();
    window.addEventListener('resize', setRemUnit)
    window.addEventListener('pageshow', function(e) {
        if (e.persisted) {
            setRemUnit();
        }
    })
    window.wHRate = wHRate; //将屏幕宽高比暴露给window
}(window, document))